"use strict";
const electron = require("electron");
const path = require("path");
const url = require("url");
var _documentCurrentScript = typeof document !== "undefined" ? document.currentScript : null;
function registerDialogIpc() {
  electron.ipcMain.handle("show-dialog", async (event, title, message) => {
    const win2 = electron.BrowserWindow.fromWebContents(event.sender);
    return await electron.dialog.showMessageBox(win2, {
      title: title || "系统提示",
      message: message || "默认内容",
      type: "info",
      buttons: ["取消", "确认"]
    });
  });
}
const dialogIpc = {
  registerDialogIpc
};
function registerAllIpc() {
  dialogIpc.registerDialogIpc();
}
const __filename$1 = url.fileURLToPath(typeof document === "undefined" ? require("url").pathToFileURL(__filename).href : _documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === "SCRIPT" && _documentCurrentScript.src || new URL("main.js", document.baseURI).href);
const __dirname$1 = path.dirname(__filename$1);
let win;
const createWindow = () => {
  const preloadPath = path.join(__dirname$1, "./preload.js");
  win = new electron.BrowserWindow({
    webPreferences: {
      devTools: true,
      // 集成网页和 Node.js，建议在生产环境关闭 nodeIntegration
      nodeIntegration: process.env.NODE_ENV === "development",
      contextIsolation: true,
      // 建议开启上下文隔离，配合 preload 使用更安全
      preload: preloadPath
      // 配置预加载脚本
    }
  });
  if (process.env.NODE_ENV !== "development") {
    win.loadFile(path.join(__dirname$1, "./index.html"));
  } else {
    win.loadURL(`${process.env["VITE_DEV_SERVER_URL"]}`);
  }
};
electron.app.whenReady().then(() => {
  registerAllIpc();
  createWindow();
  electron.app.on("activate", () => {
    if (electron.BrowserWindow.getAllWindows().length === 0) createWindow();
  });
});
electron.app.on("window-all-closed", () => {
  if (process.platform !== "darwin") {
    electron.app.quit();
  }
});
